#pragma once

#include <string>
#include <map>
#include "Value.h"

using namespace std;
using namespace utility::common;

namespace utility{
namespace ini{


//键值对
typedef std::map<string, Value> Section;

class IniFile
{
public:
    IniFile();
    IniFile(const string& filename);

    bool load(const string & filename);

    Value & get(const string & section, const string & key);
    void set(const string &section, const string &key, const Value &value);

    bool has(const string &section,const string & key);
    bool has(const string &section);

    void remove(const string &section, const string &key);
    void remove(const string &section);

    string str();
    void show();

    bool save(const string & filename);

    void clear();

    Section & operator [](const string &section)
    {
        return m_sections[section];
    }
private:
    string trim(string s);

private:
    string m_filename;
    std::map<string, Section> m_sections;
};
}
}